﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="EnterSales2.aspx.cs" Inherits="Auditors_EnterSales2" %>

<%@ Register src="topnav.ascx" tagname="topnav" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../Scripts/cookies.js" type="text/javascript"></script>
    <script>



        function GoTotxtDateY() {
            var oEvent = window.event;
            if (oEvent.keyCode == 13 && !oEvent.ctrlKey) {


                $("#txtDateY").focus();
                event.returnValue = false;

            }
        }

        function GoTotxtDateM() {
            var oEvent = window.event;
            if (oEvent.keyCode == 13 && !oEvent.ctrlKey) {


                $("#txtDateM").focus();
                event.returnValue = false;

            }
        }

        function GoTotxtDateD() {
            var oEvent = window.event;
            if (oEvent.keyCode == 13 && !oEvent.ctrlKey) {


                $("#txtDateD").focus();
                event.returnValue = false;

            }
        }
        function GoTotxtAmount() {
            var oEvent = window.event;
            if (oEvent.keyCode == 13 && !oEvent.ctrlKey) {


                $("#txtAmount").focus();
                event.returnValue = false;

            }
        }
        function GoTodropCurrency() {
            var oEvent = window.event;
            if (oEvent.keyCode == 13 && !oEvent.ctrlKey) {


                $("#<%=dropCurrency.ClientID %>").focus();
                event.returnValue = false;

            }
        }

        function GoTotxtOrderNo() {
            var oEvent = window.event;
            if (oEvent.keyCode == 13 && !oEvent.ctrlKey) {


                $("#txtOrderNo").focus();
                event.returnValue = false;

            }
        }

        function GoTotxtCustomer() {
            var oEvent = window.event;
            if (oEvent.keyCode == 13 && !oEvent.ctrlKey) {


                $("#txtCustomer").focus();
                event.returnValue = false;

            }
        }

        function GoTotxtOffering() {
            var oEvent = window.event;
            if (oEvent.keyCode == 13 && !oEvent.ctrlKey) {


                $("#txtOffering").focus();
                event.returnValue = false;

            }
        }

        function remove(index) {
            var v = Cookies.getCookie("Sale");
            if (v != null) {
                var strs = v.toString().split(";");
                var str = "";
                for (var i = 0; i < strs.length - 1; i++) {
                    if (i != index) {
                        str += strs[i] + ";";
                    }
                }

                Cookies.setCookie("Sale", str, 1, "/");
            }
            show();
        }

        function insert() {
            var oEvent = window.event;
            if (oEvent.keyCode == 13 && !oEvent.ctrlKey) {


                var v = Cookies.getCookie("Sale");
                if (v == null) {
                    v = "";
                }

                v += $("#txtVoucherNo").val();
                v += "~";
                v += $("#txtDateY").val();
                v += "-";
                v += $("#txtDateM").val();
                v += "-";
                v += $("#txtDateD").val();
                v += "~";
                v += $("#txtOrderNo").val();
                v += "~";
                v += $("#txtCustomer").val();
                v += "~";
                v += $("#txtOffering").val();
                v += "~";
                v += $("#txtAmount").val();
                v += "~";
                v += $("#<%=dropCurrency.ClientID %>").val();
                v += ";";
                Cookies.setCookie("Sale", v, 1, "/");
                show();


                $("#txtOrderNo").val("");
                $("#txtCustomer").val("");
                $("#txtOffering").val("");
                $("#txtAmount").val("");

                $("#txtDateY").focus();
                event.returnValue = false;
            }
        }

        function show() {
            var v = Cookies.getCookie("Sale");
            if (v != null) {
                var str = "<table>";
                str += "<tr>";
                str += "<th>";
                str += "     凭证";
                str += "</th>";
                str += "<th>";
                str += "     日期";
                str += "</th>";
                str += "<th>";
                str += "    订单号";
                str += "</th>";
                str += "<th>";
                str += "    客户";
                str += "</th>";
                str += "<th>";
                str += "    商品";
                str += "</th>";
                str += "<th>";
                str += "    金额";
                str += "</th>";
                str += "<th>";
                str += "    币种";
                str += "</th>";
                str += "</tr>";

                var strs = v.toString().split(";");
                for (var i = 0; i < strs.length - 1; i++) {
                    str += "<tr>";
                    var strs2 = strs[i].toString().split("~");
                    for (var l = 0; l < strs2.length; l++) {
                        str += "<td>";
                        if (l != 6) {
                            str += strs2[l];
                        } else {

                            str += x[strs2[l]];
                        }
                        str += "</td>";
                    }
                    str += "<td>";
                    str += "<a href='#' onclick=remove(" + i + ")>remove</a>";
                    str += "</td>";
                    str += "</tr>";
                }

                str += "</table>";

                $("#div1").html(str);
                //
            }
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
     <script>

         function GoTo(page, id, orderid) {
             window.location.href = page + "?CompanyID=" + id + "&orderid=" + orderid;
         }
    </script>
    <uc1:topnav ID="topnav1" runat="server" />
    <div id="div1">
        
    </div>
    <table id="myTable">
        <tr>
            <th>
                凭证
            </th>
            <th>
                日期
            </th>
            <th>
                订单号
            </th>
            <th>
                客户
            </th>
            <th>
                商品
            </th>
            <th>
                金额
            </th>
            <th>
                币种
            </th>
        </tr>
        <tr>
            <td>
                <input id="txtVoucherNo" type="text" onkeypress="GoTotxtDateY();"  style="width: 120px"/>
            </td>
            <td>
               <input id="txtDateY" type="text" onkeypress="GoTotxtDateM();" style="width: 55px" />
                <input id="txtDateM" type="text" onkeypress="GoTotxtDateD();" style="width: 20px" />
                <input id="txtDateD" type="text" onkeypress="GoTotxtOrderNo();" style="width: 20px" />
            </td>
            <td>
                <input id="txtOrderNo" type="text" onkeypress="GoTotxtCustomer();" style="width: 120px" />
            </td>
            <td>
                <input id="txtCustomer" type="text" onkeypress="GoTotxtOffering();" style="width: 120px" />
            </td>
            <td>
                <input id="txtOffering" type="text" onkeypress="GoTotxtAmount();"  style="width: 120px"/>
            </td>
            <td>
                <input id="txtAmount" type="text" onkeypress="GoTodropCurrency();" style="width: 120px" />
            </td>
            <td>
                <asp:DropDownList ID="dropCurrency" runat="server" onkeydown="insert();">
                </asp:DropDownList>
                
            </td>
        </tr>
    </table>
    <script>

        $(function () {
            //            var v = Cookies.getCookie("Sale");
            //            if (v != null) {
            //                Cookies.setCookie("Sale", "", -1, "/");
            //            }
            show();
        });
        
    </script>
    <asp:Button ID="Button1" runat="server" Text="保存" onclick="Button1_Click" UseSubmitBehavior="false"  />
    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

</asp:Content>
